<template>
  <div>
    <component
      :is="FormCard"
      :enum-name="enumName"
      @render="render"
    />
    <component
      :is="TableCard"
      ref="TableCard"
      :enum-name="enumName"
      @detailCarrier="detailCarrier"
      @render="render"
      @updateCarrier="updateCarrier"
      @delCarrier="delCarrier"
    />
  </div>
</template>

<script>
import FormCard from '@/components/FormCard'
import TableCard from '@/components/TableCard'
import { getPageCarrier } from '@/api/carrier'

export default {
  components: {
    FormCard,
    TableCard
  },
  data() {
    return {
      FormCard,
      TableCard,
      enumName: 'carrier',
      // btnData: {
      //   show: false
      // },
      data: {
        id: '',
        size: 10,
        descs: 'createTime',
        current: 1
      }
    }
  },
  computed: {
  },
  async mounted() {
    await this.render()
  },
  methods: {
    detailCarrier(value) {
      console.log(value)
    },
    updateCarrier(value) {
      console.log(value)
    },
    delCarrier(value) {
      console.log(value)
    },
    async  render(params = {}) {
      console.log(params)
      this.data = { ...this.data, ...params }
      const { data } = await getPageCarrier({ ...this.data, ...params })
      this.$refs.TableCard.basicData = data.records
      this.$refs.TableCard.total = +data.total
      this.$refs.TableCard.size = +data.size
      this.$refs.TableCard.current = +data.current
    }
  }

}
</script>

<style>
</style>
